<template>
  <div class="about">
    <div class="movWrap">
      <dl>
        <dt><img :src="detailList.img" alt="" /></dt>
        <dd>
          <h3><span>名称：</span>{{ detailList.name }}</h3>
          <p><span>主演：</span>{{ detailList.acter }}</p>
          <p><span>导演：</span>{{ detailList.people }}</p>
          <p><span>简介：</span>{{ detailList.word }}</p>
        </dd>
      </dl>
      <div class="block">
        <span class="demonstration">评分{{ detailList.fen }}</span>
        <el-rate v-model="value1"></el-rate>
      </div>
    </div>
    <div class="comWrap">
      <el-input v-model="input" placeholder="请输入内容"></el-input><button @click="addComs">发送</button>
      <button @click="addFive">追加评论</button>
      <el-tabs v-model="activeName" @tab-click="handleClick">
        <el-tab-pane label="热门" name="second"></el-tab-pane>
        <el-tab-pane label="最新" name="third"></el-tab-pane>
        <el-tab-pane label="好友" name="fourth"></el-tab-pane>
      </el-tabs>
      <ul>
        <li v-for="(v, i) in comments" :key="i">
          <h4>{{ v.comname }}</h4>
          <p>{{ v.content }}</p>
        </li>
      </ul>
    </div>
  </div>
</template>
<script>
import { getUrl, postUrl } from "../utils/request";
export default {
  data() {
    return {
      m_id: localStorage.getItem("m_id"),
      detailList: {},
      value1: 0,
      comments: [],
      pageSize: 5,
      type:'',
      activeName:'second',
      input:''
    };
  },
  methods: {
    async getDetail() {
      const res = await getUrl("/getDetail", { m_id: this.m_id });
      // console.log(res);
      this.detailList = res.data;
      this.value1 = res.data.fen / 2;
    },
    async getCom() {
      const res = await postUrl("/getcomment", {
        m_id: this.m_id,
        pageIndex: 0,
        pageSize: this.pageSize,
        type:this.type
      });
      console.log(res);
      this.comments = res.data;
    },
    addFive() {
      this.pageSize = this.pageSize + 5;
      this.getCom();
    },
    handleClick(tab){
      this.type=tab.label
      this.getCom()
    },
    async addComs(){
      const res=await postUrl('/addComm',{
        m_id:this.m_id,
        input:this.input
      })
      this.getCom();
      if(res.data.code===200){
        alert(res.data.mes)
        this.activeName='third'
      }else{
        alert(res.data.mes)
      }
      console.log(res)
    }
  },

  created() {
    this.getDetail();
    this.getCom();
  },
};
</script>
<style lang="scss">
.about {
  width: 800px;
  height: 100%;
  margin: 0 auto;
  background: #fff;
  .movWrap {
    width: 100%;
    display: flex;
    dl {
      width: 600px;
      display: flex;
      padding: 10px;
      dt {
        width: 250px;
        height: 280px;
        img {
          width: 100%;
          height: 100%;
        }
      }
    }
  }
}
</style>